package com.translate.web.api.controller;
import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.response.vo.ResponseModel;
import com.controller.base.AbstractCommonController;
import com.translate.entity.ExamineCategory;
import com.jwt.IJwtUtil;
import com.translate.web.param.ExamineCategoryAddParam;
import com.translate.web.param.ExamineCategoryUpdateParam;
import com.translate.web.param.contract.IExamineCategoryAddParam;
import com.param.impl.IdPageParam;
import com.translate.web.service.IExamineCategoryService;
import com.basic.service.contract.IBaseService;
import com.translate.vo.ExamineCategoryVO;
@RestController
@RequestMapping("examineCategory")public class ExamineCategoryController extends AbstractCommonController<ExamineCategory, IdPageParam> { private IExamineCategoryService service;
private IJwtUtil jwtUtil;
public ExamineCategoryController(IExamineCategoryService service) {
this.service = service;
}
@Override
protected IBaseService<ExamineCategory>getBaseService() {
return this.service;
	}
protected <VO> Class<VO> getTarget() {
return  (Class<VO>)ExamineCategoryVO.class;}
protected long getUserId(HttpServletRequest httpServletRequest) {
		return jwtUtil.getId(httpServletRequest.getHeader(jwtUtil.getJwtConfig().getHeader()));
	}
/**
 * 添加
* 
 * @param <V>
 * @param param
 * @return
*/	@PostMapping("/add")
	public ResponseModel<Integer> insert(@RequestBody @Validated ExamineCategoryAddParam param, HttpServletRequest httpServletRequest) {
 setCreateInfo(param, httpServletRequest);
int id = this.service.parseInsert(param, ExamineCategory.class);

return ResponseModel.<Integer>success(id);
}protected  long setCreateInfo(IExamineCategoryAddParam param,HttpServletRequest httpServletRequest) {
		long userId = this.getUserId(httpServletRequest);
		return userId;
	}@Autowired
	 public void setJwtUtil(IJwtUtil jwtUtil) {this.jwtUtil = jwtUtil;}
/**
* 添加
* 
 * @param <V>
 * @param param
 * @return
 */
@PostMapping("/update")
public ResponseModel<Integer> update(@Validated @RequestBody ExamineCategoryUpdateParam param, HttpServletRequest httpServletRequest) {
int res = this.service.parseUpdate(param, ExamineCategory.class);
return ResponseModel.<Integer>success(res);
}
}